package com.designpattern.behavior.memento.white_box;

/**
 * @author Administration
 * @date 2021/10/28 - 14:23 - 星期四
 * @project 行为型模式中  备忘录模式 “白箱”备忘录模式  发起人（Originator）角色
 * @package com.designpattern.behavior.memento.white_box
 * @by 晨
 */
public class GameRole {

    private Integer vit; //生命力
    private Integer atk; //攻击力
    private Integer def; //防御力

    // 初始化状态
    public void initState () {
        this.vit = 100;
        this.atk = 100;
        this.def = 100;
    }

    // 战斗
    public void fight () {
        this.vit = 0;
        this.atk = 0;
        this.def = 0;
    }

    // 保存当前角色状态
    public RoleStateMemento saveState() {
        return new RoleStateMemento(vit, atk, def);
    }

    //回复角色状态
    public void recoverState(RoleStateMemento roleStateMemento) {
        this.vit = roleStateMemento.getVit();
        this.atk = roleStateMemento.getAtk();
        this.def = roleStateMemento.getDef();
    }

    public void stateDisplay() {
        System.out.println("角色生命力：" + vit);
        System.out.println("角色攻击力：" + atk);
        System.out.println("角色防御力：" + def);
    }

    public GameRole() {
    }

    public GameRole(int vit, int atk, int def) {
        this.vit = vit;
        this.atk = atk;
        this.def = def;
    }

    public int getVit() {
        return vit;
    }

    public void setVit(int vit) {
        this.vit = vit;
    }

    public int getAtk() {
        return atk;
    }

    public void setAtk(int atk) {
        this.atk = atk;
    }

    public int getDef() {
        return def;
    }

    public void setDef(int def) {
        this.def = def;
    }
}
